package com.itheima.health.mobile.controller;

import com.itheima.health.common.MessageConst;
import com.itheima.health.common.RedisConst;
import com.itheima.health.entity.Result;
import com.itheima.health.service.SmsService;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("mobile/validateCode")
@Slf4j
public class ValidateCodeController {
    @DubboReference
    private SmsService smsService;

    /**
     * @Author: 位帅帅
     * @Date: 20:00 2021/1/11
     * @Params: [type, telephone]
     * @RerurnType: com.itheima.health.entity.Result
     * @Description: 发送验证码
    */
    @RequestMapping("send")
    public Result send(String type,String telephone) {
        log.info("[发送验证码-参数]type: {}, telephone: {}",type,telephone);
        Integer validateCode = smsService.sendValidateCode(type,telephone);
        log.info("[发送验证码-结果]validateCode: {}",validateCode);
        return new Result(true, MessageConst.SEND_VALIDATECODE_SUCCESS,validateCode);
    }
}
